﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Modeling.Diagrams;

namespace DSLFactory.VSCTDesigner
{
    class DynamicImageField : ImageField
    {

        public DynamicImageField(string name)
            : base(name)
        {
        }

        public override System.Drawing.Image GetDisplayImage(ShapeElement parentShape)
        {
            CommandWithIcon btn = parentShape.Subject as CommandWithIcon;
            if( btn != null && btn.Icon != null )
            {
                var relationShip = CommandHasIcon.GetLink(btn, btn.Icon);
                return btn.Icon.ResolveImage(relationShip.IconId);
            }

            return null;
        }
    }
}
